package com.jmazgaj.satel.command;

import java.util.Arrays;

import com.jmazgaj.satel.SatelCommand;

public class DeviceNameCommand extends SatelCommand<String> {

	public enum DeviceType {
		Partition(0), Zone(1), User(2), Expander(3), Output(4);
		
		private int type;
		private DeviceType(int type) {
			this.type = type;
		}
		
		public byte getType() {
			return (byte)type;
		}
	}

	private DeviceType deviceType;
	private byte deviceNumber;
	
	
	public DeviceNameCommand(DeviceType deviceType, byte deviceNumber) {
		this.deviceType = deviceType;
		this.deviceNumber = deviceNumber;
	}

	@Override
	protected int getActionCode() {
		return 0xEE;
	}

	@Override
	protected byte[] getRequestData() {
		return new byte[] {deviceType.getType(), deviceNumber};
	}

	@Override
	protected int getResponseDataLength() {
		return 19;
	}

	@Override
	protected String processResponse(byte[] response) {		
		return new String(Arrays.copyOfRange(response, 3, 19));
	}

}
